from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base # 2.0开始

engine = create_engine(f'sqlite:///example.db')
Base = declarative_base()


def singleton(cls):
    _instance = None
    def wrapper(*args, **kwargs):
        nonlocal _instance
        if not _instance:
            _instance = cls(*args, **kwargs)
        return _instance
    return wrapper